package webBeans;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import beansInterfaces.BasicProductMgr;
import beansInterfaces.UserMgr;
import dto.TransportDTO;


@ManagedBean(name="transport")
@RequestScoped
public class TransportCreationBean 
{
	@EJB
	private BasicProductMgr basicProductMgr;
	@EJB
	private UserMgr u;
	
	
	private TransportDTO currentTransport;
	
	public TransportCreationBean() {}
	
	
	public void createTransport() 
	{	
		this.currentTransport.setAdmin(u.getUserDTO().getUsername());
		this.basicProductMgr.addTransport(currentTransport);
		this.currentTransport=new TransportDTO();
	}


	public TransportDTO getCurrentTransport() {
		return currentTransport;
	}

	public void setCurrentTransport(TransportDTO currentTransport) {
		this.currentTransport = currentTransport;
	}
	
	
	



	@PostConstruct
	public void initializeCurrent()
	{
		this.currentTransport = new TransportDTO();
	}
	

	
}
